package com.ding.dailyup.util;

import com.ding.dailyup.exception.AuthorizationException;

/**
 * 维护用户token
 */
public class UserTokenUtil {
	public static boolean isLogin(Long userId) {
		if (userId == null || userId == 0) {
			throw new AuthorizationException("登录已过期, 请重新登录后操作!");
		}
		return true;
	}

	public static String generateToken(Integer id) {
		return JwtHelper.createToken(id);
	}

	public static Long getUserId(String token) {
		return JwtHelper.verifyTokenAndGetUserId(token);
	}
}
